package com.cssy.yd.basic.dao.impl;

import java.util.List;
import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.cssy.yd.basic.dao.BasicCurrencyDAO;
import com.cssy.yd.basic.entity.BasicCurrencyDO;
import com.plat.helper.SearchConditions;

/**
 * 数据访问对象实现类
 * @since 2013-04-24
 */
public class BasicCurrencyDAOImpl extends SqlMapClientDaoSupport implements BasicCurrencyDAO {

    /**
     * 插入数据
     * @param basicCurrencyDO
     * @return 插入数据的主键
     */
    public Integer insertBasicCurrencyDO(BasicCurrencyDO basicCurrencyDO) throws DataAccessException {
        Object id = getSqlMapClientTemplate().insert("BasicCurrency.insert", basicCurrencyDO);
        return (Integer) id;
    }

    /**
     * 统计记录数
     * @param basicCurrencyDO
     * @return 查出的记录数
     */
    public Integer countBasicCurrencyDOByExample(BasicCurrencyDO basicCurrencyDO) throws DataAccessException {
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("BasicCurrency.countByDOExample", basicCurrencyDO);
        return count;
    }

    /**
     * 更新记录
     * @param basicCurrencyDO
     * @return 受影响的行数
     */
    public Integer updateBasicCurrencyDO(BasicCurrencyDO basicCurrencyDO) throws DataAccessException {
        int result = getSqlMapClientTemplate().update("BasicCurrency.update", basicCurrencyDO);
        return result;
    }

    /**
     * 获取对象列表
     * @param basicCurrencyDO
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    public List<BasicCurrencyDO> findListByExample(BasicCurrencyDO basicCurrencyDO) throws DataAccessException {
        List<BasicCurrencyDO> list = getSqlMapClientTemplate().queryForList("BasicCurrency.findListByDO", basicCurrencyDO);
        return list;
    }

    /**
     * 根据主键获取basicCurrencyDO
     * @param id
     * @return basicCurrencyDO
     */
    public BasicCurrencyDO findBasicCurrencyDOByPrimaryKey(String id) throws DataAccessException {
        BasicCurrencyDO basicCurrencyDO = (BasicCurrencyDO) getSqlMapClientTemplate().queryForObject("BasicCurrency.findByPrimaryKey", id);
        return basicCurrencyDO;
    }

    /**
     * 删除记录
     * @param id
     * @return 受影响的行数
     */
    public Integer deleteBasicCurrencyDOByPrimaryKey(String id) throws DataAccessException {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("BasicCurrency_ex.deleteById", id);
        return rows;
    }

    @Override
   	public List<BasicCurrencyDO> find(SearchConditions scs)
   			throws DataAccessException {
   		System.out.println(scs.getPrefix());
   		List<BasicCurrencyDO> list = getSqlMapClientTemplate().queryForList("BasicCurrency_ex.find", scs);
   		   return list;
   	}

   	@Override
   	public Integer count(SearchConditions scs) throws DataAccessException {		
   		 Integer count = (Integer) getSqlMapClientTemplate().queryForObject("BasicCurrency_ex.count", scs);
   	      return count;
   	}

}